<script type="text/javascript" charset="utf-8"
	src="js/kind/kindeditor.js"></script>
<script type="text/javascript">
$(function(){
	$("select[name='type_id']").val("{$v[type_id]}");
	$("select[name='go_type']").val("{$v[go_type]}");
	$("select[name='level']").val("{$v[level]}");
	$("select[name='inqun']").val("{$item_id}");
});
</script>
<div class="event_pbox">
	<iframe id="uploadframe" name="uploadframe" width="0" height="0"
		marginwidth="0" frameborder="0" src="about:blank"
		style="display: none; z-index: 0;"></iframe>
	<form name="FORM" id="FORM" method="post"
		action="index.php?mod=event&code=pevent" enctype="multipart/form-data"
		target="uploadframe">

		<table>
			<tr>
				<td>
					<table id="step1" align="left">
						<tr>
							<td width="100"><span>*</span>标题：</td>
							<td><input type="text" size="30" maxlength="50" id="name"
								name="name" value="{$title}" class="inputs"> <sup
								id="name_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span>*</span>活动类型：</td>
							<td>{eval $type=eventType()} <select name="type_id">
									{loop $type $k $t}
									<option value="{$k}">{$t}</option> {/loop}
							</select>
							</td>
						</tr>
						<tr>
							<td><span>*</span>出行方式：</td>
							<td>{eval $type=eventGoType()} <select name="go_type">
									{loop $type $k $t}
									<option value="{$k}">{$t}</option> {/loop}
							</select>
							</td>
						</tr>
						<tr>
							<td><span>*</span>活动难度：</td>
							<td>{eval $type=eventLevel()} <select name="level">
									{loop $type $k $t}
									<option value="{$k}">{$t}</option> {/loop}
							</select>
							</td>
						</tr>
						<tr>
							<td><span>*</span>开始：</td>
							<td><sup class="vote_endtime input"> <input id="fromt"
									name="fromt" value="{$fromt}"
									onclick="WdatePicker({minDate:'%y-%M-%d'})" type="text"
									readonly="readonly" size=6 class="inputs2">
									&nbsp;&nbsp;
									{$hour_select_from}&nbsp;时&nbsp;&nbsp;{$min_select_from}&nbsp;分
							</sup> <sup id="fromt_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<tr>
							<td><span>*</span>结束：</td>
							<td><sup class="vote_endtime input"> <input id="tot"
									name="tot" value="{$tot}"
									onclick="WdatePicker({minDate:'%y-%M-%d'})" type="text"
									readonly="readonly" size=6 class="inputs2">
									&nbsp;&nbsp;
									{$hour_select_to}&nbsp;时&nbsp;&nbsp;{$min_select_to}&nbsp;分
							</sup> <sup id="tot_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<tr>
							<td><span>*</span>领队姓名：</td>
							<td><input type="text" size="30" maxlength="50"
								id="captain_name" name="captain_name" value="{$v[captain_name]}">
								<sup id="captain_name_tips"
								style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span></span>领队电话：</td>
							<td><input type="text" size="30" maxlength="50"
								id="captain_phone" name="captain_phone"
								value="{$v[captain_phone]}"> <sup
								id="captain_phone_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span></span>领队QQ：</td>
							<td><input type="text" size="30" maxlength="50"
								id="captain_qq" name="captain_qq" value="{$v[captain_qq]}">
								<sup id="captain_qq_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span></span>副领队姓名：</td>
							<td><input type="text" size="30" maxlength="50"
								id="vice_captain_name" name="vice_captain_name"
								value="{$v[vice_captain_name]}"> <sup
								id="vice_captain_name_tips"
								style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span></span>副领队电话：</td>
							<td><input type="text" size="30" maxlength="50"
								id="vice_captain_phone" name="vice_captain_phone"
								value="{$v[vice_captain_phone]}"> <sup
								id="vice_captain_phone_tips"
								style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td><span></span>副领队QQ：</td>
							<td><input type="text" size="30" maxlength="50"
								id="vice_captain_qq" name="vice_captain_qq"
								value="{$v[vice_captain_qq]}"> <sup
								id="vice_captain_qq_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
							<td valign="top"><span>*</span>集合地点：</td>
							<td><input type="hidden" id="hid_province"
								name="hid_province" value="11"> <input type="hidden"
								id="hid_city" name="hid_city" value="176"> <input
								type="hidden" id="hid_area" name="hid_area" value="2154">
								<input type="text" id="address" name="address"
								value="{$address}" size="30" maxlength="50"> <sup
								id="address_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<tr>
							<td valign="top"><span>*</span>目的地：</td>
							<td><input type="text" id="destination" name="destination"
								value="{$v[destination]}" size="30" maxlength="50"> <sup
								id="destination_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<!--{if $top == 'top'}-->
						<tr>
							<td align="center">&nbsp;</td>
							<td><input type="button" id="next2" name="next2" value="下一步"
								onclick="set_step(2,this.form);return false;" class="btnText"></td>
						</tr>
						<!--{/if}-->
					</table>
				</td>
			</tr>
		</table>

		<table>
			<tr>
				<td>
					<table id="step2" align="left">
						<tr>
							<td><span>*</span>活动说明:（最多2000个字）<br> <textarea
									name="content1" class="kindEditor" id="content1"
									style="width: 625px; height: 300px;">{$content}</textarea> <sup
								id="content1_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<tr>
							<td><span>*</span>行程安排:（最多2000个字）<br> <textarea
									name="plan" class="kindEditor" id="plan"
									style="width: 625px; height: 300px;">{$v[plan]}</textarea> <sup
								id="plan_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
						<tr>
							<td><span>*</span>活动装备:（最多2000个字）<br> <textarea
									name="equip" class="kindEditor" id="equip"
									style="width: 625px; height: 300px;">{$v[equip]}</textarea> <sup
								id="equip_tips" style="display: none; color: #FF0000;"></sup></td>
						</tr>
						<tr>
						<tr>
							<td><span>*</span>报名须知:（最多2000个字）<br> <textarea
									name="must_know" class="kindEditor" id="must_know"
									style="width: 625px; height: 300px;">{$v[must_know]}</textarea>
								<sup id="must_know_tips" style="display: none; color: #FF0000;"></sup>
							</td>
						</tr>
						<tr>
							<td><span>*</span>上传活动海报： <input type="file" id="pic"
								name="pic" onchange="onloadPic();"> <sup id="message"
								style="display: none; color: #FF0000;"></sup> <sup
								id='uploading' style="display: none"><img
									src="images/loading.gif">图片正在上传中、请稍等...</sup> <sup
								id="hid_pic_tips" style="display: none; color: #FF0000;"></sup>
								<input type="hidden" id="hid_pic" name="hid_pic"
								value="{$image}"></td>
						</tr>
						<tr id="img" style="display: none">
							<td><img id="showimg" name="showimg" src="{$image}"
								height="90" width="100"></img></td>
						</tr>
						<!--{if $top == 'top'}-->
						<tr>
							<td align="center"><input type="button" id="back1"
								name="back1" value="上一步"
								onclick="set_step(1,this.form);return false;" class="canlText"
								style="display: inline"> <input type="button" id="next3"
								name="next3" value="下一步"
								onclick="set_step(3,this.form);return false;" class="btnText"
								style="display: inline"></td>
						</tr>
						<!--{/if}-->
					</table>
				</td>
			</tr>
		</table>

		<table>
			<tr>
				<td>
					<table id="step3" align="left">
						<tr>
							<td>人均费用： <label><input type="radio" id="money_r"
									name="money_r" value="money"
									{$money} onclick="choosemoney('money');">费用为</label> <input
								type="text" id="money" name="money" size="1" maxlength="5"
								readonly="readonly" value="$moneys"> 元 <label><input
									type="radio" id="money_r" name="money_r" value="free"
									{$free} onclick="choosemoney('free');">免费</label>
							</td>
						</tr>
						<tr>
							<td>报名资格： <label><input type="radio" id="qua"
									name="qua" value="all" {$all} onclick="chooseuser('all');" />所有用户</label><input
								type="text" style="display: none"> <label><input
									type="radio" id="qua" name="qua" value="qua"
									{$qua} onclick="chooseuser('qua');" />指定圈子</label>
							</td>
						</tr>
						<tr id="user" style="display: none">
							<td>选择圈子:&nbsp; <!-- 
            <label><input type="checkbox" id="fans" name="fans" onclick="choosefans();" {$fans}>粉丝数不少于</label>
            <input type="text" id="fans_num" name="fans_num" readonly size=1 maxlength=5 value="{$fans_num}"><br>
            <label><input type="checkbox" id="same_city" name="same_city" {$same_city}>同城用户<br></label>
             --> <!-- {if $qun} --> <select name="inqun">
									<!-- {loop $qun $t} -->
									<option value="{$t[qid]}" />{$t[name]}
									</option>
									<!-- {/loop} -->
							</select> <!-- {else} --> 抱歉,你木有所属任何圈子 <!-- {/if} --> <!--{if $item_id}-->
								<label><input type="checkbox" id="inqun" name="inqun"
									{$inqun} value="{$item_id}">{$this->Config[changeword][weiqun]}用户</label>
								<!--{/if}-->
							</td>
						</tr>
						<!--{if $info}-->
						<tr>
							<td>勾选报名时需要用户填写的内容：</td>
						</tr>
						<tr>
							<td>
								<!--{loop $info $key1 $val1}--> <label><input
									type="checkbox" id="{$val1['fieldid']}"
									name="info[{$val1['fieldid']}]" value={$key1}{$val1['checked']}>$val1['title']</label>
								<!--{/loop}-->
							</td>
						</tr>
						<!--{/if}-->
						<tr>
							<td align="center">
								<!--{if $top == 'top'}--> <input type="button" id="back2"
								name="back2" value="上一步"
								onclick="set_step(2,this.form);return false;" class="canlText">
								<!--{/if}--> <input type="button" name="SUBMIT" value="发布"
								onclick="formSubmit();" class="btnText"> <input
								type="hidden" id="top" name="top" value="{$top}"> <input
								type="hidden" id="act" name="act" value="{$act}"> <input
								type="hidden" id="id" name="id" value="{$id}">
							</td>
						</tr>
					</table>
				</td>
			</tr>
		</table>
	</form>
	<div id="publish_share"></div>
	<script type="text/javascript">
function set_step(num,form){
	if(num == 1){
		$('#step1').show();
		$('#step2').hide();
		$('#step3').hide();
	}else if(num == 2){
		var check = checkEventStep1();
		if(check == false){return false;}
		$('#step1').hide();
		$('#step2').show();
		$('#step3').hide();
	}else if(num == 3){
		var check = checkEventStep2();
		if(check == false){return false;}
		
		$('#step1').hide();
		$('#step2').hide();
		$('#step3').show();
	}
}
<!--{if $top == 'top'}-->
$(document).ready(function() {
set_step(1);
})
<!--{/if}-->
function checkEventStep1(){
	var name = $("#name").val();
	if(strlen(name) < 2){
		$("#name_tips").html("标题必须有哦");
		$("#name_tips").show();
		$("#name").focus();
		return false;
	}else{$("#name_tips").hide();}

	var fromt = $("#fromt").val();
	if(!fromt){
		$("#fromt_tips").html("开始时间必须有哦");
		$("#fromt_tips").show();
		$("#fromt").focus();
		return false;
	}else{$("#fromt_tips").hide();}

	var tot = $("#tot").val();
	if(!tot){
		$("#tot_tips").html("结束时间必须有哦");
		$("#tot_tips").show();
		$("#tot").focus();
		return false;
	}else{$("#tot_tips").hide();}
	
	var captain_name = $("#captain_name").val();
	if(!captain_name){
		$("#captain_name_tips").html("领队人名必须有哦");
		$("#captain_name_tips").show();
		$("#captain_name").focus();
		return false;
	}else{$("#captain_name_tips").hide();}
	
	
	//var address1 = $("#city").val();
	var address2 = $("#address").val();
	if(strlen(address2) < 2){
		$("#address_tips").html("集合地点必须有哦");
		$("#address_tips").show();
		$("#address").focus();
		return false;
	}else{$("#address_tips").hide();}
	
	var address2 = $("#destination").val();
	if(strlen(address2) < 2){
		$("#destination_tips").html("目的地必须有哦");
		$("#destination_tips").show();
		$("#destination").focus();
		return false;
	}else{$("#destination_tips").hide();}
	
	return true;
}

function checkEventStep2(){
	var content =  KindEditor.instances[0].html();
	$("#content1").val(content);
	if(strlen(content) < 2){
		$("#content1_tips").html("活动描述必须有哦");
		$("#content1_tips").show();
		$("#content1").focus();
		return false;
	}else{
		$("#content1_tips").hide();
	}
	
	var content =  KindEditor.instances[1].html();
		$("#plan").val(content);
	if(strlen(content) < 2){
		$("#plan_tips").html("行程安排必须有哦");
		$("#plan_tips").show();
		$("#plan").focus();
		return false;
	}else{
		$("#plan_tips").hide();
	}
	
	var content =  KindEditor.instances[2].html();
		$("#equip").val(content);
	if(strlen(content) < 2){
		$("#equip_tips").html("活动装备必须有哦");
		$("#equip_tips").show();
		$("#equip").focus();
		return false;
	}else{
		$("#equip_tips").hide();
	}
	
	var content =  KindEditor.instances[3].html();
		$("#must_know").val(content);
	if(strlen(content) < 2){
		$("#must_know_tips").html("报名须知必须有哦");
		$("#must_know_tips").show();
		$("#must_know").focus();
		return false;
	}else{
		$("#must_know_tips").hide();
	}
	
	var hid_pic = $("#hid_pic").val();
	if(!hid_pic){
		$("#hid_pic_tips").html("活动海报必须有哦");
		$("#hid_pic_tips").show();
		$("#hid_pic").focus();
		return false;
	}else{$("#hid_pic_tips").hide();}
	
	return true;
}
function onloadPic(){
	var fn = $('#pic').val();
	if (!/.(gif|jpg|png|jpeg)$/i.test(fn)) {
		alert("请上传jpg、jpeg、gif、png格式的图片。");
		return false;
	}
	var top = $('#top').val();
	if(top == 'top'){
		document.getElementById('back1').style.display = 'none';
		document.getElementById('next3').style.display = 'none';
	}
	document.getElementById('uploading').style.display = 'block';
	document.FORM.target="uploadframe";
	document.FORM.action="ajax.php?mod=event&code=onloadPic";
	$('#FORM').submit();
  }

function formSubmit(){
	if(false === checkEventStep1()){
		return false;
	}
	if(false === checkEventStep2()){
		return false;
	}
	document.FORM.target="";
	var top = document.getElementById('top').value;
	var post_data = $('#FORM').serialize();
	$.post(
		"ajax.php?mod=event&code=create&item="+__APPITEM__+"&item_id="+__APPITEM_ID__, 
		post_data, 
		function(r){
			if(!is_json(r)){
				var handle_key = 'publish_share';
				showDialog(handle_key, 'local', '分享', {html:r}, 500);
				
				$('#topic_simple_close_btn').click(
					function() {
						location.href = "index.php?mod=event&code=detail&id="+$("#topic_simple_item_id").val();
					}
				);
				$('#topic_simple_share_btn').click(
					function () {
						var response = function() {
							location.href = "index.php?mod=event&code=detail&id="+$("#topic_simple_item_id").val();
						}
						publishSimpleTopic($('#topic_simple_content').val(), 'event', $("#topic_simple_item_id").val(), {response:response})
					}
				);
			}else{
				var json = eval('('+r.toString()+')');
				if (json.done) {
					if(top){
					    MessageBox('notice',json.msg);
						if($('#i_already').length > 0){
							$('#i_already').val(json.retval.content);
						}else{
							$('#i_alreadyajax').val(json.retval.content);
						}
						//$('#i_already').val(json.retval.content);
						//$('#mapp_item').val(json.retval.from);
						//$('#mapp_item_id').val(json.retval.id);
						$(".menu_hdb").hide();
					}else{
						MessageBox('notice',json.msg);
						location.href = "index.php?mod=event&code=detail&id="+json.retval.id;
					}
				} else {
					if(json.msg.indexOf('发布成功')>0){
						show_message_2(json.msg);
						if(!top){
							location.href = "index.php?mod=event&code=myevent";
						}else{
							$(".menu_hdb").hide();
						}
					}
					MessageBox('warning', json.msg);
				}
			}
		}
	);
}

function chooseuser(t){
  if(t == 'all'){
	document.getElementById("user").style.display = "none";
  }else if('qua'){
	document.getElementById("user").style.display = "block";
  }
}
<!--{if $qua}-->
$(document).ready(function() {
chooseuser('qua');
})
<!--{/if}-->
	
function choosemoney(t){
  if(t == 'money'){
	document.getElementById("money").readOnly = false;
  }else if(t == 'free'){
	document.getElementById("money").readOnly = "readonly";
  }
}
<!--{if $money}-->
$(document).ready(function() {
choosemoney('money');
})
<!--{/if}-->

function choosefans(){
  var fans = document.getElementById("fans").checked;
  if(fans){
    document.getElementById("fans_num").readOnly = false;
  }else{
	document.getElementById("fans_num").readOnly = "readonly";
  }
}
$(document).ready(function() {
choosefans();
})

<!--{if $image}-->
function setStyle(){
  document.getElementById("img").style.display = 'block';
}
$(document).ready(function() {
setStyle();
})
<!--{/if}-->
</script>
	<script src="js/date/WdatePicker.js" type="text/javascript"></script>
</div>